#include "AdjacencyListDirectedGraph.h"

using namespace CloudZ;

AdjacencyListDirectedGraph::AdjacencyListDirectedGraph()
{
}

AdjacencyListDirectedGraph::~AdjacencyListDirectedGraph()
{
}

void AdjacencyListDirectedGraph::addEdge(int v, int u)
{
	if (v >= _adjacencyLists.size()) _adjacencyLists.resize(v + 1);
	if (u >= _adjacencyLists.size()) _adjacencyLists.resize(u + 1);
	_adjacencyLists[v].push_back(u);
}

std::list<int> & AdjacencyListDirectedGraph::getEdges(int v)
{
	return _adjacencyLists[v];
}
void AdjacencyListDirectedGraph::print(std::ostream &out)
{
	/*
	for (std::vector<std::list<int>>::const_iterator it = this->_adjacencyLists.begin();
		it != this->_adjacencyLists.end();
		++it)
	{
		
	}*/
	for (int i = 0; i < this->_adjacencyLists.size(); i++)
	{
		out << i << ": ";
		for (std::list<int>::iterator it = this->_adjacencyLists[i].begin();
			it != this->_adjacencyLists[i].end();
			++it)
		{
			out << *it << ", ";
		}
		out << std::endl;
	}
}
